<?php
/**
 * Created by PhpStorm
 * User: Jhinwy
 * Date: 11/26/24
 * Time: 4:49 PM
 */

namespace app\adminapi\logic\skits;


use app\common\model\skits\SkitsBanner;
use app\common\logic\BaseLogic;


/**
 * SkitsBannerLogic
 * Class SkitsFollowLogic
 * @package app\adminapi\logic
 */
class SkitsBannerLogic extends BaseLogic
{


    /**
     * @notes 添加
     * @param array $params
     * @return bool
     * @author likeadmin
     * @date 2024/07/13 15:05
     */
    public static function save(array $params): bool
    {
        $appId   = $params['app_id'] ?? 0;
        $skitsId = $params['skits_id'] ?? 0;
        $sort    = $params['sort'] ?? 1;

        $banner = SkitsBanner::where('app_id', $appId)->where('skits_id', $skitsId)->findOrEmpty();
        if ($banner->isEmpty()) {
            $banner           = new SkitsBanner();
            $banner->app_id   = $appId;
            $banner->skits_id = $skitsId;
        }
        $banner->sort = $sort;

        return $banner->save();
    }


    /**
     * @notes 删除
     * @param array $params
     * @return bool
     * @author likeadmin
     * @date 2024/07/13 15:05
     */
    public static function delete(array $params): bool
    {
        return SkitsBanner::destroy($params['id']);
    }

}
